package com.ysd.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.impl.ProductDaoImpl;
import com.ysd.entity.Product;

public class ProductDetailServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String pId = request.getParameter("pId");// 接受前台传来的参数
		ProductDaoImpl pDao = new ProductDaoImpl();
		Product product = pDao.getProductById(pId); //根据产品id查询产品
		request.setAttribute("product", product);
		
		request.getRequestDispatcher("productdetails.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
